package com.fr.chart.core;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.base.equals.Equals;
import com.fr.report.io.xml.ReportXMLUtils;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Rectangle2D.Double;
import java.io.Serializable;

public class Shadow
  implements Cloneable, Serializable
{
  private static final long serialVersionUID = 316720726448090470L;
  public static final String XML_TAG = "Shadow";
  private Shape shape;
  private float offset = 0.0F;

  public Shadow(Shape paramShape)
  {
    this.shape = paramShape;
  }

  public void paint(Graphics paramGraphics)
  {
    if (this.shape == null)
      return;
    float f = 3.0F;
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Paint localPaint = localGraphics2D.getPaint();
    Rectangle2D localRectangle2D = this.shape.getBounds2D();
    localGraphics2D.translate(localRectangle2D.getX(), localRectangle2D.getY());
    localGraphics2D.setPaint(new GradientPaint((float)localRectangle2D.getWidth(), 0.0F, new Color(120, 120, 120), this.offset + (float)localRectangle2D.getWidth() + f, 0.0F, Color.WHITE));
    localGraphics2D.fill(new Rectangle2D.Double(localRectangle2D.getWidth(), 0.0D, this.offset + f, localRectangle2D.getHeight()));
    localGraphics2D.translate(-localRectangle2D.getX(), -localRectangle2D.getY());
    localGraphics2D.setPaint(localPaint);
  }

  public void setShape(Shape paramShape)
  {
    this.shape = paramShape;
  }

  public Shape getShape()
  {
    return this.shape;
  }

  public void setOffset(float paramFloat)
  {
    this.offset = paramFloat;
  }

  public float getOffset()
  {
    return this.offset;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof Shadow))
      return false;
    Shadow localShadow = (Shadow)paramObject;
    if (!(Equals.euqalsShape(localShadow.shape, this.shape)))
      return false;
    return (localShadow.offset == this.offset);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      this.shape = ReportXMLUtils.readShape(paramXMLableReader);
      if (paramXMLableReader.getTagName().equals("Attr"))
      {
        String str;
        if ((str = paramXMLableReader.getAttr("offset")) != null)
          this.offset = Float.parseFloat(str);
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("Shadow");
    paramXMLPrintWriter.startTAG("Attr").attr("offset", this.offset).end();
    if (getShape() != null)
      ReportXMLUtils.writeShape(paramXMLPrintWriter, getShape());
    paramXMLPrintWriter.end();
  }
}